package com.whjz.dcfs.util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.ibatis.sqlmap.client.SqlMapClient;

public class StringUtil {
	public static Long getSequenceValByName(String seqName,SqlMapClient sqlMapClient) throws SQLException
	{
		Long result = null;
		Connection conn = null;
		Statement stmt = null;
		ResultSet rSet = null;
		try {
			conn = sqlMapClient.getDataSource().getConnection();
			stmt = conn.createStatement();
			rSet = stmt.executeQuery("select "+seqName+".nextVal val from dual");
			rSet.next();
			result = rSet.getLong("val");
		} catch (Exception e) {
			e.printStackTrace();
			throw new SQLException(e.getMessage());
		}finally
		{
			if(rSet!=null)
			{
				rSet.close();
			}
			if(stmt!=null)
			{
				stmt.close();
			}
			if(conn!=null)
			{
				conn.close();
			}
		}
		return result;
	}
}
